#!usr/bin/env python
# -*- coding:utf-8 -*-
# user nanme: Mr.zhang
# data1 time : 2022/4/14   6:21 下午
# project   : sql_language.py
# IDE       : PyCharm
# email     :17600960626@163.com
import logging

from lib.read_sql import db

def zhu_name():
    '''主语言简码'''
    zhu_names =[]
    sql ='select * from zhu_lang where `code`=0'
    a=db.selectDb(sql)
    for i in a[1]:
        zhu_names.append(i[1])
    return zhu_names


def zhu_language():
    '''获取状态为0的主语言字典'''
    zhu_dic=[]
    zhu_Dics = {
        "de": "Deutsch",
        "en_GB": "English(United Kingdom)",
        "es": "Español",
        "es_LA": "Español(América Latina)",
        "es_US":"Español(Estados Unidos)",
        "fr": "Français",
        "it": "Italiano",
        "en_US":"English(United States)"
    }
    sql = 'select zhu_table from zhu_lang where `code`=0'
    a = db.selectDb(sql)
    for i in a[1]:
        zhu_dic.append(zhu_Dics[i[0]])
    return zhu_dic


def fu_language():
    '''获取状态为0的副语言字典'''
    fu_dics= []
    fu_Dics = {
        "de": "Deutsch",
        "en_GB": "English(United Kingdom)",
        "en_US":"Español(América Latina)",
        "es": "Español",
        "es_US": "Español(América Latina)",
        "fr": "Français",
        "it": "Italiano",
        "pt_PT":"Português (Portugal)",
        "nl":"Nederlands",
        "cs":"Čeština",
        "fr_EU":"Français(Union Européenne)",
        "ro":"Română",
        "es_LA":"Español(América Latina)",
    }
    sql = 'select fu_table from zhu_lang where `code`=0'
    a = db.selectDb(sql)
    for i in a[1]:
        fu_dics.append(fu_Dics[i[0]])
    return fu_dics


def sql_devices():
    '''自动运行调用---获取状态为0的设备'''
    devices = []
    sql = 'select devices from zhu_lang where `code`=0'
    a=db.selectDb(sql)
    for i in a[1]:
        devices.append(i[0])
    return devices


def sql_dev_table():
    '''独立运行调用---获取为code为0的设备'''
    devices=[]
    sql = 'SELECT * FROM dev_table WHERE `code`=0'
    b=db.selectDb(sql)
    for i in b[1]:
        devices.append(i[1])
    return devices


def sql_dev():
    '''获取devices、path、corpus'''
    sql_path = []
    sql = 'select devices from zhu_lang where `code`=0'
    a = db.selectDb(sql)
    for i in a[1]:
        sql1 = "SELECT path_table,devices,zhu_table,fu_table FROM zhu_lang WHERE devices='%s' AND `code`=0" % i[0]
        b = db.selectDb(sql1)
        for n in b[1]:
            sql_path.append(n)
    return sql_path


def zhu_swk():
    '''获取状态为0的swk主语言字典'''
    zhu_dic=[]
    zhu_Dics = {
        "de": "德语（德国）",
        "en_GB": "英语（英国）",
        "es": "西班牙语（西班牙）",
        "es_US": "西班牙语（美国）",
        "fr": "法语（法国）",
        "it": "意大利语（意大利）",
        "en_US":"英语（美国）"
    }
    sql ='select zhu_table from zhu_lang where `code`=0'
    a=db.selectDb(sql)
    for i in a[1]:
        zhu_dic.append(zhu_Dics[i[0]])
    return zhu_dic


def fu_swk():
    '''获取状态为0的swk副语言字典'''
    fu_dics= []
    fu_Dics = {
        "de": "德语（德国）",
        "en_GB": "英语（英国）",
        "en_US":"英语（美国）",
        "es": "西班牙语（西班牙）",
        "es_US": "西班牙语（美国）",
        "fr": "法语（法国）",
        "it": "意大利语（意大利）",
        "pt_PT":"葡萄牙语（葡萄牙）",
        "nl":"荷兰语（荷兰）",
        "cs":"Čeština",
        "fr_EU":"法语（比利时）",
        "ro":"罗马尼亚语",
        "es_LA":"西班牙语（拉丁美洲）",
    }
    sql = 'select fu_table from zhu_lang where `code`=0'
    a = db.selectDb(sql)
    for i in a[1]:
        fu_dics.append(fu_Dics[i[0]])
    return fu_dics